<template>
  <div :class="['subPage',{'hidden':visible || noChildRegular || noWomanRegular}]" @touchstart="touchstart">
    <scroll-view :scroll-y="true" :style="{height: (disab && !disab2)||(disab3 && !disab4)?'80%':'100%'}" >

    <div class="mainContent">
      <div class="navBox">
        <div class="navTop">
          <span class="circular"></span>
          <span class="lineClass"></span>
          <span class="circular"></span>
          <span class="lineClass opacityClass"></span>
          <span class="circular opacityClass"></span>
          <span class="lineClass opacityClass"></span>
          <span class="circular opacityClass"></span>
        </div>
        <div class="navBom">
          <span>选择科室</span>
          <span>信息确认</span>
          <span>费用支付</span>
          <span>预约成功</span>
        </div>
      </div>
      <div class="centBox">
        <div class="userMsg">
          <div class="divTop">
            {{
              interrogationKey == "1"
                ? "图文问诊"
                : interrogationKey == "2"
                ? "音频问诊"
                : interrogationKey == "5"
                ? "开药门诊"
                : interrogationKey == "3"
                ? "专科门诊"
                : "专家问诊"
            }}
          </div>
          <div class="divCenter" v-if="interrogationKey != '3'&&interrogationKey != '5'">
            <span>{{ doctorInfo.doctor_name }}</span>
            <span
              >{{ doctorInfo.dept_name }}<span class="slash">&nbsp;/&nbsp;</span
              >{{ doctorInfo.positional_title }}</span
            >
          </div>
          <div class="divCenter" v-else>
            <span>{{ doctorInfo.dept_name }}</span>
            <!-- <span>{{doctorInfo.positional_title}}<span class="slash">&nbsp;/&nbsp;</span>{{doctorInfo.dept_name}}</span> -->
          </div>
          <div class="divBom">
            <span v-if="interrogationKey != '3' && interrogationKey != '4' && interrogationKey != '5'"
              >{{ date }}<span class="slash">&nbsp;/&nbsp;</span>{{ time }}</span
            >
            <span v-if="interrogationKey == '4'"
              >{{ doctorInfo.arrange_day_timestamp
              }}<span class="slash">&nbsp;/&nbsp;</span
              >{{ doctorInfo.period_id == 1 ? "上午" : "下午" }}</span
            >
            <span v-if="interrogationKey == '3' || interrogationKey == '5'"
              >{{ doctorInfo.arrange_day }}<span class="slash">&nbsp;/&nbsp;</span
              >{{ doctorInfo.period }}&nbsp;&nbsp;{{ doctorInfo.begin_time }} -
              {{ doctorInfo.end_time }}</span
            >
            <span
              ><span class="redClolr">¥</span
              >{{
                interrogationKey == "1"
                  ? doctorInfo.image_text_price
                  : interrogationKey == "2"
                  ? doctorInfo.video_price
                  : interrogationKey == "3" || interrogationKey == "5"
                  ? doctorInfo.registration_fee
                  : doctorInfo.registration_fee
              }}</span
            >
            <!-- <div v-if="interrogationKey == '3'"><span><span class="redClolr">¥</span>{{interrogationKey == '1' ?  doctorInfo.image_text_price : interrogationKey == '2' ? doctorInfo.video_price :  interrogationKey == '3' ? doctorInfo.used_tick : doctorInfo.used_tick}}</span></div> -->
          </div>
          <!--  -->
        </div>
        <div class="detailsBox">
          <div class="choiceBox" @click="chooseCom">
            选择就诊人
            <div class="iconBox">
              <span>点击选择</span>
              <img :src="rightIcon" />
            </div>
          </div>
          <div class="msgBox">
            <div>
              <span class="labelClass">就诊人员：</span>
              <span>{{
                userDetails.regular_name ? userDetails.regular_name : ""
              }}</span>
              <span v-if="userDetails.is_main == 1" class="identityClass"
                >本人</span
              >
            </div>
            <div>
              <span class="labelClass">身份证号：</span>
              <span>{{
                userDetails.regular_certid ? userDetails.regular_certid : ""
              }}</span>
            </div>
            <div>
              <span class="labelClass">手机号：</span>
              <span>{{
                userDetails.regular_phone ? userDetails.regular_phone : ""
              }}</span>
            </div>
          </div>
          <div class="describeBox">
            <div class="iptBox">
              <!-- <i-input placeholder="病情描述（必填）" type="textarea" v-model="step.current_medical_history" @change="describeChange" maxlength="100" class="ipt" /> -->
              <!-- <i-input :value="step.current_medical_history" type="textarea" title="详细地址" placeholder="请输入详细地址(最多50字)" maxlength="50" i-class="ipt" /> -->
              <!-- <textarea v-if="disab && !disab2" :disable-default-padding="true" placeholder-style='color:#999999;font-size: 28rpx;'  placeholder="请详细描述您的疾病症状，治疗用药情况；在下方上传近期的病历、处方、检验、检查等资料，方便医生更好的为您解答" @blur="bindblur" :auto-focus="true" v-model="step.current_medical_history" @change="describeChange" maxlength="100" :fixed="true" auto-height class="ipt" /> -->
              <textarea
                v-if="disab && !disab2"
                :disable-default-padding="true"
                placeholder-style="color:#333;font-size: 30rpx;"
                style="color: #333"
                @blur="bindblur"
                :focus="true"
                v-model="step.current_medical_history"
                @change="describeChange"
                maxlength="200"
                class="ipt"
                :placeholder="'请详细描述您的疾病症状，治疗用药情况（病情描述需要在10字以上，在下方上传近期的病历、处方、检验、检查等资料，方便医生更好的为您解答）：'"
              />
              <div v-if="!disab && !disab2" class="ipt3" style="text-" @click="showDisab">
                <span class="required"  v-if="(step.current_medical_history.length===0)&&!disab && !disab2">*</span>
                请详细描述您的疾病症状，治疗用药情况（病情描述需要在10字以上，在下方上传近期的病历、处方、检验、检查等资料，方便医生更好的为您解答）：
              </div>
              <div v-if="disab2" class="ipt" @click="showDisab" style="color: #333">
                {{ step.current_medical_history }}
              </div>
            </div>
            <div class="record" style="border-bottom:1rpx solid #e9e9e9">
              {{ step.current_medical_history.length }}/200字
            </div>
            <div class="uploadBox" :style="{'height':files.length>3?'340rpx':'165rpx'}">
              <div class="uploadRight">
                <div
                  class="upload uploadImgBox"
                  v-for="(item, index) in files"
                  :key="index"
                >
                  <img :src="item" @click="previewImage($event, index)" />
                  <!-- <img src="/static/images/close.png" class="closeClass"  > -->
                </div>
                <div v-if="files.length<8" class="upload selectBox" @click="chooseImage">
                  <img src="/static/images/add_image.png"/>
                </div>
              </div>
              <!-- <div class="upload selectBox" @click="chooseImage">
                <img src="/static/images/add_image.png"/>
              </div> -->
                <div v-if='files.length==0' style="width:72%" class="uploadRight secTip">
                上传相关图片（近期的病例、处方、检验、检查等）
              </div>
            </div>
            <div class="iptBox" style="border-top:1rpx solid #e9e9e9" v-if="interrogationKey == '5'">
              <div style="color:#333;font-size: 32rpx;letter-spacing: 3rpx;line-height:32rpx" @click="goOpenMedical">
                <div  v-if="!step.want_help" style="text-indent:1em;line-height:42rpx;" class="ipt3 constHeight">
                  <span v-if="drugList.length === 0" class="required2" >*</span>
                  为了确保药品准确性，请详细填写药品信息，以便医生准确开药，同时希望您能上传药品图片：
                </div>
                <div v-if="step.want_help" style="min-height: 215rpx; color: #333" class="drugList">
<!--                    {{step.want_help}}-->
                  <div v-for="(item, index) in drugList" :key="index">
                    <div>{{'药品:' + item.name + ' 规格:' + item.sku + ' 数量:'+ item.num}}</div>
                  </div>
                </div>
              </div>
            </div>
            <div class="iptBox" style="border-top:1rpx solid #e9e9e9" v-else>
              <textarea
                v-if="disab3 && !disab4"
                :disable-default-padding="true"
                placeholder-style="color:#333;font-size: 32rpx;letter-spacing: 3rpx;line-height:32rpx"
                @blur="bindblur2"
                :focus="true"
                v-model="step.want_help"
                maxlength="50"
                class="ipt constHeight"
                :placeholder="'希望获得的帮助：'"
              />
              <div v-if="!disab3 && !disab4"  class="ipt3 constHeight" @click="showDisab2">
                <span class="required" v-if="step.want_help.length===0 && !disab3 && !disab4" >*</span>
                希望获得的帮助：
              </div>
              <div  v-if="disab4" class="ipt constHeight" @click="showDisab2" style="color: #333">
                  {{  step.want_help }}
              </div>
            </div>
            <div class="record" v-if="interrogationKey != '5'">
              {{ step.want_help.length }}/50字
            </div>
          </div>
        </div>
        <div class="caseBox">
          <div class="caseTitle">
            就诊人健康信息
            <span @click="editConsultInfo">
              {{regularCase === null ? '添加个人信息' : '更改'}}
            </span>
          </div>
          <div v-if="regularCase !== null">
            <div class="caseTit">既往病史</div>
            <div class="caseData" v-if="regularCase.anamnesis.jb!==''">
              <div class="diseaseTit">
                疾病史: &nbsp;{{ regularCase.anamnesis.jb}}
              </div>
            </div>
            <div class="caseData" v-if="regularCase.anamnesis.crb!==''">
              <div class="diseaseTit">
                传染病史: &nbsp;{{ regularCase.anamnesis.crb}}
              </div>
            </div>
            <div class="caseData" v-if="regularCase.anamnesis.sss!==''">
              <div class="diseaseTit">
                手术史: &nbsp;{{ regularCase.anamnesis.sss}}
              </div>
            </div>
            <div class="caseData" v-if="regularCase.anamnesis.qt!==''">
              <div class="diseaseTit">
                其他补充: &nbsp;{{ regularCase.anamnesis.qt}}
              </div>
            </div>
            <!-- <div class="otherBox" v-if="regularCase.anamnesis.qt!==''">
              <span>其他补充:</span>
              {{ regularCase.anamnesis.qt}}
            </div> -->
            <div class="caseBox">
              <div class="caseTit">过敏史</div>
              <div class="caseData" v-if="regularCase.allergy_history.ywgm!==''">
                <div class="diseaseTit">
                  药物过敏: &nbsp;{{ regularCase.allergy_history.ywgm}}
                </div>
              </div>
              <div class="caseData" v-if="regularCase.allergy_history.swgm!==''">
                <div class="diseaseTit">
                  食物及其他过敏: &nbsp;{{ regularCase.allergy_history.swgm}}
                </div>
              </div>
              <div class="caseData" v-if="regularCase.allergy_history.qt!==''">
                <div class="diseaseTit">
                  其他补充: &nbsp;{{ regularCase.allergy_history.qt}}
                </div>
              </div>
              <!-- <div class="otherBox" v-if="regularCase.allergy_history.qt!==''">
                <span>其他补充:</span>
                {{ regularCase.allergy_history.qt}}
              </div> -->
            </div>
            <div class="caseBox" v-if="userDetails.regular_type==1">
              <div class="caseTit" v-if="regularCase.obsterical_history.hyzk!==''||regularCase.obsterical_history.syzt!==''" >婚育史</div>
              <div class="caseData" v-if="regularCase.obsterical_history.hyzk!==''">
                <div class="diseaseTit">
                  婚姻状况: &nbsp;{{ regularCase.obsterical_history.hyzk}}
                </div>
              </div>
              <div class="caseData" v-if="regularCase.obsterical_history.syzt!==''">
                <div class="diseaseTit">
                  生育妊娠状态: &nbsp;{{ regularCase.obsterical_history.syzt}}
                </div>
              </div>
            </div>
            <div class="caseBox">
              <div class="caseTit">家族史</div>
              <div class="caseData" v-if="regularCase.family_history.jzs_jsz!==''">
                <div class="diseaseTit">
                {{ regularCase.family_history.jzs_jsz}}
                </div>
              </div>
              <div class="caseData" v-if="regularCase.family_history.qt!==''">
                <div class="diseaseTit">
                  其他补充: &nbsp;{{ regularCase.family_history.qt}}
                </div>
              </div>
              <!-- <div class="otherBox" v-if="regularCase.family_history.qt!==''">
                <span>其他补充:</span>
                &nbsp;{{ regularCase.family_history.qt}}
              </div> -->
            </div>
            <div class="caseBox">
              <div class="caseTit">个人习惯</div>
              <div class="caseData">
                <div class="diseaseTit">
                {{ regularCase.personal_habits.grxg_grxg===''?'无':regularCase.personal_habits.grxg_grxg}}
                </div>
              </div>
              <div class="caseData" v-if="regularCase.personal_habits.qt!==''">
                <div class="diseaseTit">
                  其他补充: &nbsp;{{ regularCase.personal_habits.qt}}
                </div>
              </div>
              <!-- <div class="otherBox" v-if="regularCase.personal_habits.qt!==''">
                <span>其他补充:</span>
              {{ regularCase.personal_habits.qt}}
              </div> -->
            </div>
          </div>
          <div class="noStasticImg" v-else>
            <img :src="noDataImg"  />
            <span class="desc">暂无相关数据</span>
          </div>
        </div>

        <div
          class="btnBox"
          :style="{ 'pointer-events': disabledShow }"
          @click="toSuccess"
        >
          确认预约
        </div>
      </div>
      <div class="modalClass" v-if="paymentModal"></div>
      <div class="modalClass" v-if="modalStyle == 'felx'">
        <div class="modalBox">
          <!-- <div class="modalTit">
              <img src="/static/images/videoTit.png">
            </div> -->
          <div class="closeBox" @click="close">
            <img :src="closeImg" />
          </div>
          <div class="modalCenter">
            <picker-view indicator-style="height:50px;" style="width:100%;height:150px" :value="defaultIndex" @change="bindPickerChange">
              <picker-view-column >
                <view class="picker" v-for="item in userList" :key="item.regular_id" style="line-height:50px;text-align:center;color:rgba(34, 75, 198, 1);font-size:40rpx">{{item.regular_name}}</view>
              </picker-view-column>
            </picker-view>
          </div>
          <div class="modalFooter">
            <div class="btnLeft" @click.stop="close">取消</div>
            <div class="btnRight" @click.stop="ok">确认</div>
          </div>
        </div>
      </div>
      <div class="modalShowClass" v-if="modalShow">
        <div class="modalBox">
          <div class="closeBox" @click="closeModal">
            <img :src="closeImg" />
          </div>
          <div class="modalTit">
            选择支付方式
          </div>
          <div class="modalCenter">
            <div class="paymentBox">
              <div class="paymentLeft"></div>
              <div class="paymentCenter">
                <span class="left">现金支付</span
                ><span class="right">(支持微信支付)</span>
              </div>
              <div class="paymentRight"></div>
            </div>
            <div class="paymentBox">
              <div class="paymentLeft"></div>
              <div class="paymentCenter">
                <span class="left">医保支付</span
                ><span class="right">(支持武汉医保)</span>
              </div>
              <div class="paymentRight"></div>
            </div>
          </div>
          <div class="modalFooter" @click="tooPaymentPage">提交</div>
        </div>
      </div>
    </div>
    <div class="modal" v-if="visible">
        <div class="out">
            <div class="top" >
                <span>当前常用就诊人需要实名认证才能挂号，点击确认上传身份证进行认证</span>
            </div>
            <div class="btm">
                <span @click='visible=false'>取消</span>
                <span @click="toAddcommon">确认</span>
            </div>
        </div>
    </div>
    <div class="modal" v-if="noChildRegular">
        <div class="out">
            <div class="top" >
                <span>系统检测到您未添加儿童常用就诊人</span>
            </div>
            <div class="btm">
                <span @click='goBackPage'>返回</span>
                <span @click="addChildCommon">去添加</span>
            </div>
        </div>
    </div>
    <div class="modal" v-if="noWomanRegular">
        <div class="out">
            <div class="top" >
                <span>系统检测到您未添加女性常用就诊人</span>
            </div>
            <div class="btm">
                <span @click='goBackPage'>返回</span>
                <span @click="addWomanCommon">去添加</span>
            </div>
        </div>
    </div>
    <div class="modalClass" v-if="choosePayType">
      <div class="modalChoose">
        <div class="modalChooseInit">
          <div class="choosePayTitle">请选择患者类型</div>
          <ul>
            <li v-for="(item, index) in choosePayList" :key="index" @click="choosePay(item.value)" :class="{'choosePayCode': fee_type_code == item.value}">
              {{item.label}}
              <img v-if="fee_type_code == item.value" src="/static/images/choosePayBg.png" class="choosePayBg"/>
              <img v-if="fee_type_code == item.value" src="/static/images/choosePaySelect.png" class="choosePaySelect"/>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="gifToast" v-if="gifToast" >暂不支持gif类型图片</div>
    <i-toast id="toast" />
    <i-message id="message" />
    </scroll-view>
    <div class="mask" v-if="uploadingMask" ></div>
  </div>
  <!-- </div> -->
  <!-- </div> -->
</template>

<script>
let app = getApp();
let store = app.store;
import api from "@/api/api";
//   import { mapState } from 'vuex'
import navBar from '@/components/navBar'
import storage from "@/utils/storage";
//   import Bus from '@/utils/bus.js'
const { $Toast, $Message } = require('../../../../../static/iview/base/index')
export default {
  components: {
    navBar
  },
  data() {
    return {
      // 医保支付相关
      fee_type_code: '', // 选择的医保支付类型
      choosePayList: [
        {
          label: '普通患者',
          value: '01'
        },
        {
          label: '武汉医保',
          value: 'WHA01'
        },
      ],
      choosePayType: false,
      unload:false,
      uploadingMask: false,
      drugList: [],
      gifToast: false,
      overLarge: false,
      disab: false,
      disab2: false,
      disab3: false,
      disab4: false,
      upLoadLodin: false,
      modalShow: false,
      visible: false,
      noChildRegular: false,
      noWomanRegular: false,
      backFromComponent:false,
      timer: null, // 定时器名称
      ipt: "ipt",
      modalStyle: "none",
      disabledShow: "auto",
      doctorInfo: {},
      host: "",
      date: "",
      time: "",
      paymentModal: false,
      interrogationKey: "",
      uploadImgList: [],
      defaultIndex: [0],
      // describe: '',
      pic_array: [
        { id: 13, name: "1室1厅1卫" },
        { id: 14, name: "1室2厅1卫" },
        { id: 15, name: "2室1厅1卫" },
        { id: 16, name: "3室1厅2卫" },
        { id: 17, name: "4室1厅2卫" },
        { id: 18, name: "5室1厅3卫" },
        { id: 19, name: "6室1厅3卫" },
        { id: 20, name: "7室以上" },
      ],
      userId: "",
      hx_index: 0,
      files: [],
      upImg: [],
      diseaseList: [
        { name: "无" },
        { name: "无" },
        { name: "无" },
        { name: "无" },
        { name: "无" },
        { name: "无" },
      ],
      userList: [],
      userDetails: {
        regular_name: "",
        regular_certid: "",
        regular_phone: "",
        regular_type: "1"
      },
      arraySum: {
        // 疾病史
        list1: [
          { name: "无", key: "0", class: "" },
          { name: "哮喘", key: "1", class: "" },
          { name: "高血脂症", key: "2", class: "" },
          { name: "高血压", key: "3", class: "" },
          { name: "高尿酸血症", key: "4", class: "" },
          { name: "癫痫", key: "5", class: "" },
          { name: "心脏病", key: "6", class: "" },
          { name: "糖尿病", key: "7", class: "" },
          { name: "脑卒中", key: "8", class: "" },
          { name: "胃炎", key: "9", class: "" },
          { name: "肝炎", key: "10", class: "" },
        ],
        // 传染病史
        list2: [
          { name: "无", key: "0", class: "" },
          { name: "肺结核", key: "1", class: "" },
          { name: "病毒性肝炎", key: "2", class: "" },
          { name: "血吸虫病", key: "3", class: "" },
          { name: "淋病", key: "4", class: "" },
        ],
        // 手术史
        list3: [
          { name: "无", key: "0", class: "" },
          { name: "颅部手术", key: "1", class: "" },
          { name: "颈部手术", key: "2", class: "" },
          { name: "胸部手术", key: "3", class: "" },
          { name: "腹部手术", key: "4", class: "" },
          { name: "四肢手术", key: "5", class: "" },
          { name: "骨折", key: "6", class: "" },
          { name: "烧伤", key: "7", class: "" },
          { name: "烫伤", key: "8", class: "" },
          { name: "头部外伤", key: "9", class: "" },
          { name: "肌腱外伤", key: "10", class: "" },
        ],
        // 药物过敏
        list4: [
          { name: "无", key: "0", class: "" },
          { name: "青霉素", key: "1", class: "" },
          { name: "头孢类抗生素", key: "2", class: "" },
          { name: "破伤风抗生素", key: "3", class: "" },
          { name: "普鲁卡因", key: "4", class: "" },
          { name: "地卡因", key: "5", class: "" },
          { name: "磺胺类药物", key: "6", class: "" },
          { name: "维生素B1", key: "7", class: "" },
          { name: "泛影葡胺", key: "8", class: "" },
          { name: "阿司匹林", key: "9", class: "" },
        ],
        // 食物过敏
        list5: [
          { name: "无", key: "0", class: "" },
          { name: "芒果", key: "1", class: "" },
          { name: "牛奶", key: "2", class: "" },
          { name: "海鲜", key: "3", class: "" },
          { name: "笋", key: "4", class: "" },
          { name: "香菇", key: "5", class: "" },
          { name: "黄瓜", key: "6", class: "" },
          { name: "油漆", key: "7", class: "" },
          { name: "花粉", key: "8", class: "" },
          { name: "皮毛", key: "9", class: "" },
        ],
        // 婚姻史
        list6: [
          { name: "已婚", key: "1", class: "" },
          { name: "未婚", key: "2", class: "" },
        ],
        // 生育状态
        list7: [
          { name: "未生育", key: "1", class: "" },
          { name: "已生育", key: "2", class: "" },
          { name: "未怀孕", key: "3", class: "" },
          { name: "已怀孕", key: "4", class: "" },
        ],
        // 家族史
        list8: [
          { name: "无", key: "0", class: "" },
          { name: "高血压", key: "1", class: "" },
          { name: "糖尿病", key: "2", class: "" },
          { name: "心脏病", key: "3", class: "" },
          { name: "脑梗", key: "4", class: "" },
          { name: "脑出血", key: "5", class: "" },
          { name: "癌症", key: "6", class: "" },
          { name: "过敏性疾病", key: "7", class: "" },
          { name: "哮喘", key: "8", class: "" },
          { name: "癫痫病", key: "9", class: "" },
          { name: "白癜风", key: "10", class: "" },
        ],
        // 个人习惯
        list9: [
          { name: "无", key: "0", class: "" },
          { name: "吸烟", key: "1", class: "" },
          { name: "饮酒", key: "2", class: "" },
          { name: "熬夜", key: "3", class: "" },
          { name: "低头", key: "4", class: "" },
          { name: "久坐", key: "5", class: "" },
          { name: "久站", key: "6", class: "" },
          { name: "跷二郎腿", key: "7", class: "" },
          { name: "强忍大小便", key: "8", class: "" },
          { name: "饭后卧床", key: "9", class: "" },
          { name: "如厕看书报", key: "10", class: "" },
          { name: "不喜喝水", key: "11", class: "" },
        ],
      },
      step: {
        apt_diagnosis_time: "",
        current_medical_history: "",
        doctor_id: "",
        regular_id: "",
        type: "3",
        upload_image: [],
        want_help: ''
      },
      imgUrl: "",
      noDataImg: '',
      rightIcon: "",
      addImage: "",
      closeImg: "",
      orderData: null,
      paymentNone: false,
      saveIndex: 0,
      havGif: false,
      regularCase: null
      // {
      //   family_history: {
      //     jzs_jsz: "",
      //     qt: "",
      //   },
      //   obsterical_history: {
      //     hyzk: "",
      //     syzt: "",
      //   },
      //   personal_habits: {
      //     grxg_grxg: "",
      //     qt: "",
      //   },
      //   allergy_history: {
      //     qt: "",
      //     swgm: "",
      //     ywgm: "",
      //   },
      //   anamnesis: {
      //     crb: "",
      //     jb: "",
      //     qt: "",
      //     sss: ""
      //   },
      // }
    };
  },
  computed: {
  },
  onShow() {
    this.getRegularList();
    this.getRegularCase();
    if (
      !this.doctorInfo.image_text_price ||
      this.doctorInfo.image_text_price == 0
    ) {
      this.doctorInfo.image_text_price = "0.0";
    } else {
      this.doctorInfo.image_text_price = parseFloat(
        this.doctorInfo.image_text_price
      ).toFixed(1);
    }
    if (!this.doctorInfo.video_price || this.doctorInfo.video_price == 0) {
      this.doctorInfo.video_price = "0.0";
    } else {
      this.doctorInfo.video_price = parseFloat(
        this.doctorInfo.video_price
      ).toFixed(1);
    }
    if (
      !this.doctorInfo.registration_fee ||
      this.doctorInfo.registration_fee == 0
    ) {
      this.doctorInfo.registration_fee = "0.0";
    } else {
      this.doctorInfo.registration_fee = parseFloat(
        this.doctorInfo.registration_fee
      ).toFixed(1);
    }
    this.interrogationKey = this.$route.query.key || '5';
    this.getDateTime();
    this.modalStyle = "none";
    mpvue.getStorage({
      key: 'addDrugList',
      success: (e) => {
        let list = e.data
        console.log(list)
        this.drugList = e.data
        if(list.length > 0) {
          let str = ''
          for(let i = 0; i < list.length; i++) {
            str = `${str} 药品:${list[i].name} 规格:${list[i].sku} 数量:${list[i].num};`
          }
          this.step.want_help = str
        }
      }
    })
  },
  watch: {
    sessionsList: function (oldValue, newValue) {
      // this.dealData()
    },
  },
  onLoad(options) {
    Object.assign(this.$data, this.$options.data())
    // let info = '{"arrange_info_id":76595,"category":1,"used_tick":0,"useful_tick":5,"arrange_day":"2020-11-02","begin_time":"10:00","end_time":"10:30","period":"上午","available":true,"dept_limit":"normal","dept_name":"门重门慢","registration_fee":"4.5"}'
    this.doctorInfo = JSON.parse(this.$route.query.doctorInfo);
    // this.doctorInfo = JSON.parse(info)
    let that = this;
    that.orderData = null;
    that.paymentNone = false;
    that.paymentModal = false;
    that.disabledShow = "auto";
    that.upLoadLodin = false;
    that.modalShow = false;
    that.imgUrl = api.imgUrl;
    that.rightIcon = that.imgUrl + "rightIcon.png";
    that.addImage = that.imgUrl + "addImage.png";
    that.closeImg = that.imgUrl + "close.png";
    that.noDataImg = this.imgUrl + 'noStastic.png'
    that.timer = null;
    that.files = [];
    that.upImg = [];
    that.modalStyle = "none";
    // that.userId = null
    that.userDetails = {
      regular_name: "",
      regular_certid: "",
      regular_phone: "",
      regular_type: "1"
    };
    that.arraySum = {
      // 疾病史
      list1: [
        { name: "无", key: "0", class: "" },
        { name: "哮喘", key: "1", class: "" },
        { name: "高血脂症", key: "2", class: "" },
        { name: "高血压", key: "3", class: "" },
        { name: "高尿酸血症", key: "4", class: "" },
        { name: "癫痫", key: "5", class: "" },
        { name: "心脏病", key: "6", class: "" },
        { name: "糖尿病", key: "7", class: "" },
        { name: "脑卒中", key: "8", class: "" },
        { name: "胃炎", key: "9", class: "" },
        { name: "肝炎", key: "10", class: "" },
      ],
      // 传染病史
      list2: [
        { name: "无", key: "0", class: "" },
        { name: "肺结核", key: "1", class: "" },
        { name: "病毒性肝炎", key: "2", class: "" },
        { name: "血吸虫病", key: "3", class: "" },
        { name: "淋病", key: "4", class: "" },
      ],
      // 手术史
      list3: [
        { name: "无", key: "0", class: "" },
        { name: "颅部手术", key: "1", class: "" },
        { name: "颈部手术", key: "2", class: "" },
        { name: "胸部手术", key: "3", class: "" },
        { name: "腹部手术", key: "4", class: "" },
        { name: "四肢手术", key: "5", class: "" },
        { name: "骨折", key: "6", class: "" },
        { name: "烧伤", key: "7", class: "" },
        { name: "烫伤", key: "8", class: "" },
        { name: "头部外伤", key: "9", class: "" },
        { name: "肌腱外伤", key: "10", class: "" },
      ],
      // 药物过敏
      list4: [
        { name: "无", key: "0", class: "" },
        { name: "青霉素", key: "1", class: "" },
        { name: "头孢类抗生素", key: "2", class: "" },
        { name: "破伤风抗生素", key: "3", class: "" },
        { name: "普鲁卡因", key: "4", class: "" },
        { name: "地卡因", key: "5", class: "" },
        { name: "磺胺类药物", key: "6", class: "" },
        { name: "维生素B1", key: "7", class: "" },
        { name: "泛影葡胺", key: "8", class: "" },
        { name: "阿司匹林", key: "9", class: "" },
      ],
      // 食物过敏
      list5: [
        { name: "无", key: "0", class: "" },
        { name: "芒果", key: "1", class: "" },
        { name: "牛奶", key: "2", class: "" },
        { name: "海鲜", key: "3", class: "" },
        { name: "笋", key: "4", class: "" },
        { name: "香菇", key: "5", class: "" },
        { name: "黄瓜", key: "6", class: "" },
        { name: "油漆", key: "7", class: "" },
        { name: "花粉", key: "8", class: "" },
        { name: "皮毛", key: "9", class: "" },
      ],
      // 婚姻史
      list6: [
        { name: "已婚", key: "1", class: "" },
        { name: "未婚", key: "2", class: "" },
      ],
      // 生育状态
      list7: [
        { name: "未生育", key: "1", class: "" },
        { name: "已生育", key: "2", class: "" },
        { name: "未怀孕", key: "3", class: "" },
        { name: "已怀孕", key: "4", class: "" },
      ],
      // 家族史
      list8: [
        { name: "无", key: "0", class: "" },
        { name: "高血压", key: "1", class: "" },
        { name: "糖尿病", key: "2", class: "" },
        { name: "心脏病", key: "3", class: "" },
        { name: "脑梗", key: "4", class: "" },
        { name: "脑出血", key: "5", class: "" },
        { name: "癌症", key: "6", class: "" },
        { name: "过敏性疾病", key: "7", class: "" },
        { name: "哮喘", key: "8", class: "" },
        { name: "癫痫病", key: "9", class: "" },
        { name: "白癜风", key: "10", class: "" },
      ],
      // 个人习惯
      list9: [
        { name: "无", key: "0", class: "" },
        { name: "吸烟", key: "1", class: "" },
        { name: "饮酒", key: "2", class: "" },
        { name: "熬夜", key: "3", class: "" },
        { name: "低头", key: "4", class: "" },
        { name: "久坐", key: "5", class: "" },
        { name: "久站", key: "6", class: "" },
        { name: "跷二郎腿", key: "7", class: "" },
        { name: "强忍大小便", key: "8", class: "" },
        { name: "饭后卧床", key: "9", class: "" },
        { name: "如厕看书报", key: "10", class: "" },
        { name: "不喜喝水", key: "11", class: "" },
      ],
    };
    that.step = {
      arrange_info_id: "",
      apt_diagnosis_time: "",
      current_medical_history: "",
      doctor_id: "",
      want_help: '',
      regular_id: "",
      type: "3",
      upload_image: [],
    };
    mpvue.removeStorage({
      key: 'addDrugList',
      success (res) {
      }
    })
  },
  mounted() {},
  methods: {
    choosePay (value) {
      this.fee_type_code = value
      this.$api.setFeeTypeCode({regular_id: this.userId, fee_type_code: value}, { showLoading:  false }).then(res => {
        this.choosePayType = false
        this.fee_type_code = ''
      })
    },
    goOpenMedical() {
      this.$router.push(`/pages/index/child/addDrug/main`);
    },
    blurHandle() {},
    tooPaymentPage() {
      this.$router.replace(`/pages/subPage/register/paymentPage/main`);
    },
    closeModal() {
      this.modalShow = false;
      // this.hx_index = 0
    },
    touchstart(e) {
      // console.log('开始滚动')
      if (this.step.want_help.length == 0) {
        this.disab3 = false;
        this.disab4 = false;
      } else {
        this.disab4 = true;
        this.disab3 = false;
      }
      if (this.step.current_medical_history.length == 0) {
        this.disab2 = false;
        this.disab = false;
      } else {
        this.disab2 = true;
        this.disab = false;
      }
    },
    showDisab() {
      this.disab = true;
      this.disab2 = false;
    },
    showDisab2() {
      this.disab3 = true;
      this.disab4 = false;
    },
    bindblur(jud) {
      if (this.step.current_medical_history.length == 0) {
        this.disab2 = false;
        this.disab = false;
      } else {
        this.disab2 = true;
        this.disab = false;
      }
    },
    bindblur2() {
      if (this.step.want_help.length == 0) {
        this.disab4 = false;
        this.disab3 = false;
      } else {
        this.disab4 = true;
        this.disab3 = false;
      }
    },
    activeClick(e, key) {
      if (this.arraySum[key][e].class == "") {
        this.$set(this.arraySum[key][e], "class", "active");
      } else {
        this.$set(this.arraySum[key][e], "class", "");
      }
      if (key != "list6" && key != "list7") {
        if (e == 0) {
          this.arraySum[key].forEach((item, index) => {
            if (index != 0) {
              this.$set(this.arraySum[key][index], "class", "");
            }
          });
        } else {
          this.arraySum[key].forEach((item, index) => {
            if (index == 0) {
              this.$set(this.arraySum[key][index], "class", "");
            }
          });
        }
      } else {
        this.arraySum[key].forEach((item, index) => {
          if (index != e) {
            this.$set(this.arraySum[key][index], "class", "");
          }
        });
      }
      let list = this.arraySum[key];
      // let list1 = ''
      // let list2 = ''
      // let list3 = ''
      // let list4 = ''
      // let list5 = ''
      // let list6 = ''
      // let list7 = ''
      // let list8 = ''
      // let list9 = ''
      this.arraySum[key] = [];
      this.arraySum[key] = list;
      // console.log(this.arraySum)
    },
    removeImg(e) {
      this.files.splice(e, 1);
      this.upImg.splice(e, 1);
    },
    describeChange() {
      // console.log('输入框字数', this.step.current_medical_history)
      // if (this.describe.length == 100) {
      //   wx.showModal({
      //     title: '提示',
      //     content: '字数不能超过100个',
      //     showCancel: false
      //   })
      // }
    },
    close() {
      this.modalStyle = "none";
      this.$set(this.defaultIndex, 0, this.saveIndex)
      // this.hx_index = 0;
    },
    ok() {
      this.saveIndex = this.hx_index
      this.$set(this.defaultIndex, 0, this.hx_index)
      console.log(this.userList[this.hx_index], 'this.userList[this.hx_index]')
      if (this.userList[this.hx_index].is_real !== 1) {
        this.modalStyle = "none";
        this.userId = this.userList[this.hx_index].regular_id;
        this.visible = true
      } else {
        this.modalStyle = "none";
        this.userId = this.userList[this.hx_index].regular_id;
        this.selectUser();
        if (this.userList[this.hx_index].fee_type_code != 'WHA01') {
          this.choosePayType = true
        }
      }
    },
    selectUser() {
      this.userList.forEach((item, index) => {
        if (item.regular_id == this.userId) {
          this.userDetails = item;
          this.getRegularCase()
          return;
        }
      });
    },
    getRegularCase() {
      if (!this.userDetails.regular_id) return
      this.$api.userRegularCaseQuery({regular_id:this.userDetails.regular_id}, { showLoading:  false }).then(res => {
            this.regularCase = res.data
        })
    },
    setDefaultPatient () {
      let noneDefault = 0
      this.userList.forEach((item, index) => {
        if (item.is_default==='1') {  // 默认就诊人
          if (item.is_real != '1') {
            this.visible = true
            this.userId = this.userList[index].regular_id;
          } else {
            this.userId = this.userList[index].regular_id;
            this.selectUser();
            this.userDetails = item;
          }
          this.saveIndex = index
          this.$set(this.defaultIndex, 0, index)
          this.hx_index = index
          if (item.fee_type_code != 'WHA01') {
            this.choosePayType = true
          }
          return;
        } else {
          noneDefault ++
        }
      })
      if (noneDefault === this.userList.length) {  // 没有默认就诊人
        console.log('没有默认就诊人')
        this.userId = this.userList[0].regular_id;
        // this.selectUser();
        this.saveIndex = 0
        this.$set(this.defaultIndex, 0, 0)
        this.hx_index = 0
        this.userDetails = this.userList[0]; // 默认选中第0 个
        if (this.userList[0].fee_type_code != 'WHA01') {
          this.choosePayType = true
        }
      }
    },
    bindPickerChange(e) {
      this.hx_index = e.mp.detail.value[0];
      this.$set(this.defaultIndex, 0, e.mp.detail.value[0])
      // this.userName = e.mp.detail.name
      // console.log('picker发送选择改变，携带值为', e.detail.value);
      // this.setData({   //给变量赋值
      // hx_index: e.detail.value,  //每次选择了下拉列表的内容同时修改下标然后修改显示的内容，显示的内容和选择的内容一致
      // })
      // console.log('自定义值:', this.data.hx_select);
    },
    selectImg() {
      let that = this;
      wx.chooseImage({
        count: 8, // 默认9
        sizeType: ["original", "compressed"], // 可以指定是原图还是压缩图，默认二者都有
        sourceType: ["album", "camera"], // 可以指定来源是相册还是相机，默认二者都有
        success: function (res) {
          // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
          var tempFilePaths = res.tempFilePaths;
          // console.log(tempFilePaths)
          that.uploadImgList = tempFilePaths;
          that.upload(that, tempFilePaths);
        },
      });
    },
    chooseImage(e) {
      if (this.upLoadLodin) {
        this.$utils.showToast("text", "上传中，请稍后再试");
        return;
      }
      if (this.files.length >= 8) {
        this.$utils.showToast("text", "最多只能上传8图片");
        return;
      }
      let i = 0; // 多图上传时使用到的index
      let that = this;
      let max = 8-that.upImg.length; //当前最大选择数
      let upLength; //图片数组长度
      let imgFilePaths; //图片的本地临时文件路径列表
      wx.chooseImage({
        count: max || 1, //一次最多可以选择的图片张数
        sizeType: ["original", "compressed"], // 可以指定是原图还是压缩图，默认二者都有
        sourceType: ["album", "camera"], // 可以指定来源是相册还是相机，默认二者都有
        success: function (res) {
          console.log(res,'上传文件')
          // gif判断
          let list = []
          that.havGif = false
          res.tempFilePaths.forEach((ele,i)=>{
            let type = ele.substring(ele.length-3, ele.length)
            // 处理gif
            if (type == 'gif' || type == 'GIF') {
              that.havGif = true
            } else if (res.tempFiles[i].size > 10240000) {
              that.overLarge = true
            } else {
              list.push(ele)
            }
          })
          that.files = that.files.concat(list);
          imgFilePaths = list;
          upLength = imgFilePaths.length;
          if(upLength === 0) {
            if(that.havGif) {
              that.gifToast = true
              that.havGif = false
              setTimeout(() => {
                that.gifToast = false
              }, 2000);
            }
            if(that.overLarge) {
              wx.showToast({
                title: '上传图片应小于10MB',
                icon: 'none',
                duration: 2000
              })
              that.overLarge = false
            }
            return
          }
          let maxLen = that.upImg.length * 1 + upLength * 1;
          that.upLoadLodin = true;
          if (maxLen > 8) {
            // let duration = 2000
            // that.$utils.showToast('text', '最多只能上传8张！',{ duration })
            wx.showModal({
              title: "提示",
              content: "最多只能上传8张！",
              showCancel: false,
              success: function (res) {
                that.upLoadLodin = false;
              },
            });
            return false;
          }
          /**
           * 上传完成后把文件上传到服务器
           */
           setTimeout(() => {
             $Toast({
                content: '上传中...',
                type: 'loading',
                duration: 0
            });
           }, 300);
          that.uploadingMask = true
          that.upLoad(list, i, upLength); //上传操作
        },
        fail: function () {
          console.log('fail');
        },
        complete: function () {
        },
      });
    },
    upLoad(imgPath, i, upLength) {
      let that = this;
      let hiseeToken = storage.getToken();
      //上传文件
      wx.uploadFile({
        url: api.host + "/api/emr/upload_image",
        filePath: imgPath[i],
        name: "img0",
        header: {
          "content-type": "multipart/form-data",
          "hisee-token": hiseeToken,
          Authorization: "Bearer " + hiseeToken,
        },
        success: function (res) {
          if (res.statusCode == 200) {
            // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
            // that.files = that.files.concat(imgPath[i]); //合并图片显示数组
            let imgData = JSON.parse(res.data);
            that.upImg.push(imgData.data);
            i++;
            if (i == upLength) {
              $Toast.hide(); //上传结束，隐藏loading
              that.uploadingMask = false
              wx.showModal({
                title: "成功提示",
                content: "上传成功",
                showCancel: false,
                success: function (res) {
                  that.upLoadLodin = false;
                  if(that.havGif) {
                      wx.showToast({
                        title: '暂不支持gif类型的图片',
                        icon: 'none',
                        duration: 2000
                      })
                      that.havGif = false
                    }
                  if(that.overLarge) {
                    wx.showToast({
                      title: '上传图片应小于10MB',
                      icon: 'none',
                      duration: 2000
                    })
                    that.overLarge = false
                  }
                },
              });
            } else {
              that.upLoad(imgPath, i, upLength);
            }
            // }
          } else {
            // console.log(res);
            $Toast.hide()
            that.uploadingMask = false
            wx.showModal({
              title: "错误提示",
              content: "上传图片失败",
              showCancel: false,
              success: function (res) {
                that.files = [];
                that.upImg = [];
                that.upLoadLodin = false;
                if(that.havGif) {
                  wx.showToast({
                    title: '暂不支持gif类型的图片',
                    icon: 'none',
                    duration: 2000
                  })
                  that.havGif = false
                }
              },
            });
          }
        },
        fail: function (res) {
          console.log(res,'图片上传失败');
          $Toast.hide()
          that.uploadingMask = false
          wx.showModal({
            title: "错误提示",
            content: "上传图片失败",
            showCancel: false,
            success: function (res) {
              that.files = [];
              that.upImg = [];
              if(that.havGif) {
                wx.showToast({
                  title: '暂不支持gif类型的图片',
                  icon: 'none',
                  duration: 2000
                })
                that.havGif = false
              }
            },
          });
        },
        complete: function () {},
      });
    },
    previewImage(e, index) {
      // console.log('图片路径', e)
      // console.log('下标', index)
      let that = this;
      wx.showActionSheet({
        itemList: ["预览", "删除"],
        success: function (res) {
          if (res.tapIndex === 0) {
            // console.log('成功返回',res)
            //选择预览
            wx.previewImage({
              current: that.files[index], // 当前显示图片的http链接
              urls: that.files, // 需要预览的图片http链接列表
            });
          } else {
            //选择删除
            that.files.splice(index, 1); //删除本地图片地址数组中位置内容
            that.upImg.splice(index, 1); //删除提交给后台的图片数组中的位置内容
          }
        },
      });
    },
    getDateTime() {
      var now = new Date();
      var nowTime = now.toLocaleString();
      // var date = nowTime.substring(0,10);//截取日期
      let date = now;
      let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? "0" + MM : MM;
      let d = date.getDate();
      d = d < 10 ? "0" + d : d;
      let h = date.getHours();
      h = h < 10 ? "0" + h : h;
      let m = date.getMinutes();
      m = m < 10 ? "0" + m : m;
      let s = date.getSeconds();
      s = s < 10 ? "0" + s : s;
      date = y + "-" + MM + "-" + d;
      var time = nowTime.substring(10, 21); //截取时间
      var week = now.getDay(); //星期
      var hour = now.getHours(); //小时
      //判断星期几
      var weeks = ["日", "一", "二", "三", "四", "五", "六"];
      // var getWeek = "星期" + weeks[week];
      var sc;
      //判断是AM or PM
      if (hour >= 0 && hour < 5) {
        sc = "凌晨";
      } else if (hour > 5 && hour <= 7) {
        sc = "早上";
      } else if (hour > 7 && hour <= 11) {
        sc = "上午";
      } else if (hour > 11 && hour <= 13) {
        sc = "中午";
      } else if (hour > 13 && hour <= 18) {
        sc = "下午";
      } else if (hour > 18 && hour <= 23) {
        sc = "晚上";
      }
      // document.getElementById('time').innerHTML ="当前时间：" + date+" " + getWeek +" "+"   "+sc+"  "+time;
      // console.log('日期', date)
      let newTime = this.$utils.filterTime(new Date().getTime() / 1000, 6);
      console.log(newTime, "newTime");
      this.date = date;
      this.time = newTime;
      // setTimeout('showTime()',1000);
    },
    // 组件添加完成后触发 重新获取就诊人
    componentGetRegulat() {
      this.getRegularList()
    },
    getRegularList() {
      console.log(this.doctorInfo,'onshow',this.doctorInfo.dept_limit)
      let param = {}
      param = {
        regular_type:this.doctorInfo.dept_limit==='child'?'2':this.doctorInfo.dept_limit==='women'?'3':''
      }
      this.$api.regularList(param, { showLoading: true }).then((res) => {
        // 判断是否有儿童就诊人
        if (res.data.length===0 && param.regular_type=='2') {
          this.noChildRegular = true
          return
        } else {
          this.noChildRegular = false
        }
        // 判断是否有女性就诊人
        if (res.data.length===0 && param.regular_type=='3') {
          this.noWomanRegular = true
          return
        } else {
          this.noWomanRegular = false
        }
        this.userList = res.data;
        if(this.userDetails.regular_name != '') { // 处理在选择图片之后触发onshow 就诊人发生改变bug
          return
        }
        this.setDefaultPatient()  // 初始选中默认就诊人
      });
    },
    goBackPage() {
      this.$router.go(-1)
    },
    // 添加常用就诊人 （儿童）
    addChildCommon () {
      this.$router.push(`/pages/center/child/addCommon/main?type=2&nowBooking=true`)
    },
    // 添加常用就诊人 （成人）
    addWomanCommon () {
      this.$router.push(`/pages/center/child/addCommon/main?type=1&nowBooking=true`)
    },
    chooseCom() {
      this.modalStyle = "felx";
      console.log(this.defaultIndex)
    },
    toPayment(e) {
      let that = this;
      if(e.pay_value == 0) {  // 金额为0 跳过支付
        that.$api
          .appointmentPayResultGet(
            { order_id: e.order_id },
            { showLoading: true }
          )
          .then((res) => {
            let data = JSON.stringify(e);
            wx.hideLoading();
            $Toast({
              content: "支付成功",
              type: "success"
            });

            that.$router.replace(
              `/pages/subPage/register/registerSuccess/main?data=${data}`
            );
            clearInterval(that.timer);
            that.timer = null;
            that.paymentModal = false;
            mpvue.hideLoading()
          });
      }
      this.$api
        .orderPayWechatMini({ order_id: e.order_id }, { showLoading: true })
        .then((res) => {
          that.disabledShow = "auto";
          wx.requestPayment({
            timeStamp: res.data.signMp.timeStamp,
            nonceStr: res.data.signMp.nonceStr,
            package: res.data.signMp.package,
            signType: res.data.signMp.signType,
            paySign: res.data.signMp.sign,
            success(res) {
              that.paymentModal = true;
              var index = 0;
              function circleQuery(index) {
                that.$api
                  .appointmentPayResultGet(
                    { order_id: e.order_id },
                    { showLoading: false }
                  )
                  .then(temp => {
                    mpvue.showLoading({
                      title: "加载中...",
                      mask: true
                    });
                    if(that.unload) {
                      wx.hideLoading();
                      index = 10;
                      return
                    }
                    if (temp.data.pay_status == true) {
                        let data = JSON.stringify(e);
                        wx.hideLoading();
                        mpvue.hideLoading()
                        $Toast({
                          content: "支付成功",
                          type: "success"
                        });
                        mpvue.removeStorage({
                          key: 'addDrugList',
                          success (res) {
                          }
                        })
                        that.$router.replace(
                          `/pages/subPage/register/registerSuccess/main?data=${data}`
                        );
                        that.paymentModal = false;
                        return
                      }
                    if(index > 4) {
                      if (temp.data.pay_status == true) {
                        let data = JSON.stringify(e);
                        wx.hideLoading();
                        mpvue.hideLoading()
                        $Toast({
                          content: "支付成功",
                          type: "success"
                        });
                        mpvue.removeStorage({
                          key: 'addDrugList',
                          success (res) {
                          }
                        })
                        that.$router.replace(
                          `/pages/subPage/register/registerSuccess/main?data=${data}`
                        );
                        that.paymentModal = false;
                        return
                      } else {
                        wx.hideLoading();
                        mpvue.hideLoading()
                        that.paymentModal = false;
                        $Toast({
                          content: "支付失败",
                          type: "warning"
                        });
                        mpvue.removeStorage({
                          key: 'addDrugList',
                          success (res) {
                          }
                        })
                        that.$router.replace(`/pages/center/child/appointmentRecord/main`)
                      }
                    }
                    index++;
                    setTimeout(() => {
                        circleQuery(index)
                    }, 1000);
                    console.log(index, "现金支付");
                  });
              }
              circleQuery(index)
            },
            fail(res) {
              wx.hideLoading();
              mpvue.hideLoading()
              that.paymentModal = false;
              $Toast({
                content: "支付失败",
                type: "warning"
              });
              mpvue.removeStorage({
                key: 'addDrugList',
                success (res) {
                }
              })
              that.$router.replace(`/pages/center/child/appointmentRecord/main`)
            },
          });
        });
    },
    toSuccess() {
      let that = this
      if(this.regularCase === null) {
        this.$utils.showToast("text", "请添加就诊人健康信息");
        return
      }
      Object.assign(this.step,this.regularCase)
      if(this.step.current_medical_history.length<10){
        this.$utils.showToast("text", "病情描述需要在10字以上");
        return
      }
      if (this.disabledShow == "none") {
        return;
      }
      this.disabledShow = "none";

      this.step.doctor_id = this.doctorInfo.doctor_id;
      this.step.apt_diagnosis_time = this.date;
      // if (this.userId) {
      this.step.regular_id = this.userId;
      // }
      this.step.doctor_id =
        this.doctorInfo.doctor_id || this.doctorInfo.doctor_id;
      if (this.interrogationKey == "1" || this.interrogationKey == "2") {
        this.step.apt_diagnosis_time = this.date;
        delete this.step.arrange_info_id;
      } else {
        delete this.step.apt_diagnosis_time;
        this.step.arrange_info_id = this.doctorInfo.arrange_info_id;
        delete this.step.doctor_id;
      }
      this.step.type = this.interrogationKey == 1 ? "3" : "4";
      if (!this.step.regular_id || this.step.regular_id == "") {
        this.$utils.showToast("text", "请选择就诊人后再预约");
        this.disabledShow = "auto";
        return;
      }
      console.log(this.step.regular_id);
      if (
        !this.step.current_medical_history ||
        this.step.current_medical_history == ""
      ) {
        this.$utils.showToast("text", "请填写病情描述后再预约");
        this.disabledShow = "auto";
        return;
      }
      if (!this.step.want_help ||this.step.want_help == "") {
        this.$utils.showToast("text", that.interrogationKey == '5'?'请添加药品信息':"请填写希望获得的帮助");
        this.disabledShow = "auto";
        return;
      }
      if (
        (!this.step.anamnesis.jb ||
          !this.step.anamnesis.crb ||
          !this.step.anamnesis.sss) &&
        !this.step.anamnesis.qt
      ) {
        this.$utils.showToast("text", "请填写完整既往病史后再预约");
        this.disabledShow = "auto";
        return;
      }
      if (
        (!this.step.allergy_history.ywgm || !this.step.allergy_history.swgm) &&
        !this.step.allergy_history.qt
      ) {
        this.$utils.showToast("text", "请填写完整过敏史后再预约");
        this.disabledShow = "auto";
        return;
      }
      if (!this.step.family_history.jzs_jsz && !this.step.family_history.qt) {
        this.$utils.showToast("text", "请填写家族史后再预约");
        this.disabledShow = "auto";
        return;
      }
      this.step.upload_image = []
      this.upImg.forEach((item,i) => {
        if (i<8) {
          this.step.upload_image.push(item[0].file_key);
        }
      });
      console.log( this.step.upload_image,this.upImg)
      if (this.interrogationKey == "1" || this.interrogationKey == "2") {
        //  支付流程！！
        if (this.orderData) {
          this.toPayment(this.orderData);
          console.log("已经有了id");
          return;
        }
        this.$api
          .save(this.step, { showLoading: true })
          .then((res) => {
            let data = JSON.stringify(res.data);
            this.orderData = res.data;
            this.toPayment(res.data)  // 支付流程！！
          })
          .catch((err) => {
            console.log(err);
            this.disabledShow = "auto";
          });
      } else {  // 专科专家 开药

        // 如果入口是开药专区  带上开药专区的科室id
        if(this.doctorInfo.ky_dept_id) {
          this.step.ky_dept_id = this.doctorInfo.ky_dept_id
        }
        if (this.orderData) {
          this.toPayment(this.orderData);
          console.log("已经有了id");
          return;
        }

        this.$api
          .saveDeptDoctor(this.step, { showLoading: false })
          .then((res) => {
            console.log(res.data);
            this.orderData = res.data;
            this.toPayment(res.data);
          })
          .catch((err) => {
            this.disabledShow = "auto";
          });
      }
    },
    toAddcommon () {
      this.$router.push(
        `/pages/center/child/addCommon/main?id=${this.userId}&type=1`
      )
    },
    editConsultInfo () {
      console.log(this.userDetails)
      if(!this.userDetails.regular_id || this.userDetails.regular_id==='') {
        wx.showToast({
          title: '请选择就诊人',
          icon: 'none',
          duration: 2000
        })
        return
      }
      this.$router.push({
        path:`/pages/subPage/register/consultInfo/main`,
        query: {
          regular_certid: this.userDetails.regular_certid,
          regular_id: this.userDetails.regular_id,
          regular_name: this.userDetails.regular_name,
          regular_phone: this.userDetails.regular_phone,
          regular_type: this.userDetails.regular_type
        }
      })
    }
  },
  onUnload() {
    let that = this;
    that.step.regular_id = null;
    that.userId = null;
    that.modalStyle = "none";
    that.disab = false;
    that.disab2 = false;
    that.files = [];
    that.upImg = [];
    that.unload = true
  },
};
</script>

<style scoped lang="less">
.slash {
  color: #cccccc;
}
.redClolr {
  color: #ff5453;
  font-size: 20rpx;
}
.subPage {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
}
.hidden {
  // overflow: hidden;
}
.navBox {
  padding: 10rpx 60rpx;
  width: 630rpx;
  height: 92rpx;
  background: rgba(74, 100, 234, 1);
  .navTop {
    margin-left: 52rpx;
    span {
      display: inline-block;
    }
    .circular {
      width: 19rpx;
      height: 19rpx;
      border-radius: 50rpx;
      background: #ffffff;
      border: 1rpx solid #ffffff;
    }
    .lineClass {
      width: 150rpx;
      border-top: 1rpx solid #ffffff;
      height: 13rpx;
      line-height: 19rpx;
    }
    .opacityClass {
      opacity: 0.2;
    }
  }
  .navTop > span:nth-child(5) {
    background: none;
  }
  .navTop > span:nth-child(7) {
    background: none;
  }
  .navBom {
    span {
      display: inline-block;
      font-size: 30rpx;
      font-weight: 400;
      color: rgba(255, 255, 255, 1);
      margin-right: 50rpx;
    }
  }
  .navBom > span:nth-child(4) {
    margin-right: 0rpx;
  }
}
.centBox {
  // height: 1074rpx;
  overflow-x: hidden;
  overflow-y: auto;
  background: #f9f9f9;
  .userMsg {
    // width:690rpx;
    height: 160rpx;
    // background:rgba(245,245,245,1);
    padding: 34rpx 50rpx 37rpx 50rpx;
    background: #ffffff;
    margin-bottom: 16rpx;
    .divTop {
      height: 50rpx;
      background: rgba(235, 245, 255, 1);
      font-size: 30rpx;
      font-weight: 600;
      color: rgba(37, 143, 248, 1);
      line-height: 50rpx;
      margin-bottom: 20rpx;
      width: 140rpx;
      text-align: center;
    }
    span {
      display: inline-block;
    }
    .divCenter {
      margin-bottom: 7rpx;
    }
    .divCenter > span:nth-child(1) {
      font-size: 36rpx;
      font-weight: 600;
      color: rgba(74, 113, 232, 1);
      margin-right: 20rpx;
    }
    .divCenter > span:nth-child(2) {
      font-size: 30rpx;
      font-weight: 400;
      color: rgba(51, 51, 51, 1);
    }
    .divBom {
      display: flex;
      justify-content: space-between;
      span {
        line-height: 52rpx;
      }
      div {
        display: block;
      }
    }
    .divBom > span:nth-child(1) {
      font-size: 30rpx;
      font-weight: 400;
      color: rgba(51, 51, 51, 1);
    }
    .divBom > span:nth-child(2) {
      font-size: 40rpx;
      font-weight: 600;
      color: rgba(255, 84, 83, 1);
    }
  }
  .detailsBox > div {
    border-bottom: 1rpx solid #e9e9e9;
  }
  .detailsBox {
    background: #ffffff;
    .choiceBox {
      height: 90rpx;
      font-size: 36rpx;
      font-weight: 600;
      color: rgba(51, 51, 51, 1);
      line-height: 90rpx;
      padding-left: 40rpx;
      position: relative;
      .iconBox {
        // position: relative;
        span {
          position: absolute;
          right: 85rpx;
          top: 3rpx;
          color: #258ff8;
          font-size: 30rpx;
          font-weight: 300;
        }
        img {
          width: 17rpx;
          height: 30rpx;
          position: absolute;
          right: 30rpx;
          top: 34rpx;
        }
      }
    }
  }
  .msgBox {
    height: 150rpx;
    padding: 30rpx 40rpx 30rpx 40rpx;
    div {
      margin-bottom: 10rpx;
    }
    span {
      font-size: 30rpx;
      font-weight: 400;
      color: rgba(51, 51, 51, 1);
    }
    .identityClass {
      display: inline-block;
      width: 68rpx;
      height: 41rpx;
      background: rgba(16, 193, 91, 1);
      font-size: 24rpx;
      font-weight: 400;
      // color:rgba(255,255,255,1);
      line-height: 41rpx;
      text-align: center;
      margin-left: 20rpx;
      color: #ffffff;
    }
    .labelClass {
      display: inline-block;
      font-size: 30rpx;
      font-weight: 300;
      color: #666666;
      width: 150rpx;
    }
  }
  .msgBox > div:nth-child(3) {
    margin-bottom: 0rpx;
  }
  .describeBox {
    position: relative;
    border-bottom: 0rpx solid #e9e9e9 !important;
    textarea {
      min-height: 150rpx;
      height: auto;
    }
    .iptBox {
      position: relative;
      display: block;
      // overflow: auto;
    }
    .drugList {
      min-height: 315rpx;
      padding: 30rpx;
      letter-spacing: 3rpx;
      word-break: break-all;
      line-height: 40rpx;
    }
    .ipt {
      padding: 30rpx;
      height: 315rpx !important;
      width: 670rpx !important;
      display: block;
      color: #333;
      line-height: 32rpx;
      font-size: 30rpx;
      margin: auto;
      padding-left: 20rpx;
      letter-spacing: 3rpx;
      word-break: break-all;
    }
    .phClass {
      color: #999999;
    }
    .ipt3 {
      text-indent: 1em;
      padding: 30rpx;
      height: 315rpx !important;
      width: 670rpx !important;
      display: block;
      color: #333;
      // line-height: 32rpx;
      letter-spacing: 3rpx;
      font-size: 30rpx;
    }
    .required,.required2 {
      color: red;
      box-sizing: border-box;
      line-height: 34rpx;
      height: 30rpx;
      left: -1px;
      position: absolute;
      top: 22rpx;
      zoom: 1.5;
      color: red;
      font-size: 34rpx;
    }
    .constHeight {
      height: 215rpx !important;
    }
    .record {
      // position: absolute;
      font-size: 30rpx;
      font-weight: 300;
      color: rgba(204, 204, 204, 1);
      text-align: right;
      padding-right: 60rpx;
      padding-bottom: 24rpx;
      // bottom:50%;
      // right: 40rpx;
    }
  }
  .uploadBox {
    width: 100%;
    padding: 36rpx 30rpx 20rpx 30rpx;
    // max-height: 250rpx;
    // min-height: 120rpx;
    height: 165rpx;
    .upload {
      display: inline-block;
      width: 150rpx;
      height: 150rpx;
      background: rgba(247, 248, 250, 1);
      border-radius: 4rpx;
      float: left;
      // border: 1rpx solid rgba(204,204,204,1);
      // margin:30rpx;
      margin-right: 30rpx;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
      }
    }
    .uploadImgBox {
      position: relative;
      margin-bottom: 20rpx;
      .closeClass {
        width: 30rpx;
        height: 30rpx;
        position: absolute;
        top: 0;
        right: 0;
        z-index: 99;
      }
    }
    .uploadRight {
      // margin-left: 100rpx;
      position: relative;
      // left: 120rpx;
      // bottom: 110rpx;
      // width: 80%;
      float: left;
    }
    .selectBox {
      overflow: hidden;

      img {
        width: 100%;
        height: 100%;
      }
    }
     .secTip{
        // color: #999;
        color: #333;
        font-size: 28rpx;
        margin-top: 16px;
        // bottom: 106rpx;
      }
  }
  .caseBox {
    background: #ffffff;
    .caseTit,
    .caseTitle {
      padding-left: 30rpx;
      height: 50rpx;
      background: #ebf5ff;
      font-size: 36rpx;
      color: #4B7AEA;
      line-height: 50rpx;
    }
    .caseTitle {
      height: 89rpx;
      line-height: 89rpx;
      font-weight: 700;
      margin-bottom: 29rpx;
      span {
        float:right;
        font-weight: 500;
        margin-right: 30rpx;
        font-size: 30rpx;
        min-width: 100rpx;
        text-align: right;
      }
    }
    .caseTit {
      background: #fff;
      color: #333333;
      font-size:36rpx;
      font-weight: 700;
      margin: 6rpx 0;
    }
    .diseaseTit {
      padding: 10rpx 30rpx;
      font-size: 34rpx;
      font-weight: 400;
      color: rgba(51, 51, 51, 1);
    }
    .noStasticImg {
      position: relative;
      height: 720rpx;
      width: 100%;
      img {
        height: 100%;
        width: 100%;
      }
      .desc {
          position: absolute;
          color: #CCCCCC;
          font-size: 32rpx;
          left: 50%;
          transform: translateX(-50%);
          top: 467rpx;
        }
    }
    .diseaseBox {
      // display: flex;
      // justify-content:space-around;
      border-bottom: 1rpx solid rgba(204, 204, 204, 1);
      padding-left: 30rpx;
      li {
        width: 210rpx;
        height: 70rpx;
        background: rgba(245, 245, 245, 1);
        border: 1rpx solid rgba(245, 245, 245, 1);
        border-radius: 4rpx;
        display: inline-block;
        margin-right: 25rpx;
        margin-bottom: 30rpx;
        text-align: center;
        line-height: 70rpx;
        font-size: 30rpx;
        font-weight: 300;
        color: rgba(51, 51, 51, 1);
      }
      .active {
        border: 1rpx solid #4a71e8;
        background: rgba(235, 245, 255, 1);
        color: #4a71e8;
      }
    }
    .otherBox {
      width: 100%;
      display: flex;
      justify-content: flex-start;
      padding: 20rpx 30rpx;
      box-sizing: border-box;
      span {
        display: inline-block;
        font-size: 36rpx;

        font-weight: 400;
        color: rgba(51, 51, 51, 1);
        // padding: 20rpx 0;
      }
    }
    .otherBox > span:nth-child(1) {
      margin-right: 30rpx;
      width: 160rpx;
    }
    .otherBox > span:nth-child(2) {
      // width: ;
      flex: 1;
      padding-top: 4rpx;
      vertical-align: bottom;
    }
    .ipt2 {
      font-size: 36rpx;
      font-weight: 400;
      color: rgba(51, 51, 51, 1);
    }
  }
  .btnBox {
    margin: 30rpx;
    font-size: 36rpx;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
    text-align: center;
    height: 80rpx;
    line-height: 80rpx;
    background: #4253e1;
    border-radius: 10rpx;
  }
}
.modalShowClass {
  position: absolute;
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(0, 0, 0, 0.6);
  justify-content: flex-end;
  align-items: center;
  flex-direction: column;
  width: 100%;
  height: 100%;
  z-index: 9;

  .modalBox {
    width: 100%;
    // height:663rpx;
    z-index: 99;
    background: #ffffff;
    // border-radius:12px;
    // border-bottom-right-radius: 0;
    // border-bottom-left-radius: 0;

    .closeBox {
      width: 60rpx;
      height: 60rpx;
      position: absolute;
      right: 0rpx;
      // right: -30rpx;
      // top: -30rpx;
      img {
        width: 100%;
        height: 100%;
        z-index: 99;
      }
    }
    .modalTit {
      height: 90rpx;
      line-height: 90rpx;
      width: 100%;
      text-align: center;
      font-size: 34rpx;
      // font-family:PingFangSC-Medium,PingFang SC;
      font-weight: 500;
      color: rgba(51, 51, 51, 1);
      border-bottom: 1rpx solid #e9e9e9;
    }
    .modalCenter {
      // padding: 67rpx 30rpx 33rpx 37rpx;
      display: flex;
      flex-direction: column;
      margin-bottom: 166rpx;
      .paymentBox {
        width: 686rpx;
        height: 50rpx;
        padding: 0 32rpx;
        padding-top: 22rpx;
        padding-bottom: 28rpx;
        border-top: 1rpx solid #e9e9e9;
        border-bottom: 1rpx solid #e9e9e9;
        display: flex;
        justify-content: space-between;
        .paymentLeft {
          width: 50rpx;
          height: 50rpx;
          border: 1rpx solid red;
        }
        .paymentCenter {
          height: 50rpx;
          line-height: 50rpx;
          width: 576rpx;
          margin-left: 21rpx;
          margin-right: 21rpx;
          text-align: left;
          .left {
            font-size: 32rpx;
            font-weight: 500;
            color: #333333;
          }
          .right {
            font-size: 28rpx;
            font-weight: 400;
            color: #999999;
          }
        }
        .paymentRight {
          width: 50rpx;
          height: 50rpx;
          border: 1rpx solid red;
        }
      }
    }
    .modalFooter {
      // width:544rpx;
      height: 92rpx;
      background: rgba(74, 100, 234, 1);
      border-radius: 38rpx;
      font-size: 32rpx;
      font-weight: 600;
      color: rgba(255, 255, 255, 1);
      margin: 0 37rpx 63rpx 37rpx;
      line-height: 92rpx;
      text-align: center;
    }
    .btnDis {
      background: #c5c8ce;
    }
  }
}
.modalClass {
  position: absolute;
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(0, 0, 0, 0.6);
  justify-content: center;
  align-items: center;
  flex-direction: column;
  width: 100%;
  height: 100%;
  z-index: 9;
  // background:rgba(0,0,0,1);
  // opacity:0.6;
  .modalChoose {
    width: 660rpx;
    height: 444rpx;
    background: #fff;
    border-radius: 8px;
    .modalChooseInit {
      margin: 57rpx;
      ul {
        margin-top: 18rpx;
        li {
          height: 90rpx;
          line-height: 90rpx;
          font-size: 36rpx;
          color: #666666;
          border: 1px solid #B1B1B1;
          border-radius: 8rpx;
          text-align: center;
          margin-top: 35rpx;
          position: relative;
          .choosePayBg {
            width: 51rpx;
            height: 51rpx;
            position: absolute;
            right: -2rpx;
            top: -1rpx;
            z-index: 1;
          }
          .choosePaySelect {
            width: 20rpx;
            height: 20rpx;
            z-index: 10;
            position: absolute;
            right: 4rpx;
            top: 6rpx;
          }
        }
        .choosePayCode {
          border: 1px solid #4964E8!important;
          color: #4964E8!important;
        }
      }
      .choosePayTitle {
        height: 50rpx;
        font-size: 36rpx;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: bold;
        color: #333333;
        line-height: 50rpx;
      }
    }
  }
  .modalBox {
    width: 617rpx;
    // height:663rpx;
    z-index: 99;
    background: #ffffff;
    border-radius: 12px;
    position: relative;
    .modalTit {
      width: 100%;
      img {
        width: 100%;
        height: 220rpx;
      }
    }
    .closeBox {
      width: 60rpx;
      height: 60rpx;
      position: absolute;
      right: -30rpx;
      top: -30rpx;
      img {
        width: 100%;
        height: 100%;
        z-index: 99;
      }
    }
    .modalCenter {
      padding: 67rpx 30rpx 33rpx 37rpx;
      display: flex;
      flex-direction: column;
      .picClass {
        height: 131rpx;
        line-height: 131rpx;
        text-align: center;
        border-top: 1rpx solid #e9e9e9;
        border-bottom: 1rpx solid #e9e9e9;
        div {
          font-size: 50rpx;
          font-weight: normal;
          color: rgba(34, 75, 198, 1);
        }
      }
      .dataBox {
        margin-bottom: 40rpx;
        span {
          display: inline-block;
          font-size: 28rpx;
          font-weight: 400;
          color: rgba(102, 102, 102, 1);
          vertical-align: middle;
        }
        .itemPie {
          width: 12rpx;
          height: 12rpx;
          background: rgba(74, 100, 234, 1);
          border-radius: 50%;
          margin-right: 15rpx;
          // vertical-align: middle;
          margin-bottom: 5rpx;
        }
        .itemSpan {
          width: 95%;
        }
      }
    }
    .modalFooter {
      div {
        width: 50%;
        height: 90rpx;
        font-size: 36rpx;
        font-weight: 400;
        display: inline-block;
        text-align: center;
        line-height: 90rpx;
      }
      .btnLeft {
        background: rgba(247, 248, 250, 1);
        border-radius: 0rpx 0rpx 0rpx 24rpx;
        color: #333333;
        box-sizing: border-box;
      }
      .btnRight {
        background: rgba(74, 100, 234, 1);
        border-radius: 0rpx 0rpx 24rpx 0rpx;
        color: #ffffff;
        box-sizing: border-box;
      }
    }
    .btnDis {
      background: #c5c8ce;
    }
  }
}
.modal {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    background: rgba(0,0,0,.7);
    opacity: 1;
    z-index: 100;
    .out {
      height: 412rpx;
      border-radius: 15rpx;
      width: 650rpx;
      background: #fff;
      z-index: 999;
      position: absolute;
      left: 50%;
      top: 50%;
      margin-top: -206rpx;
      margin-left: -325rpx;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      .top {
        flex: 1;
        padding: 110rpx 48rpx 0 48rpx;
        text-align: center;
        span {
          font-size: 34rpx;
          font-family:PingFangSC-Regular,PingFangSC;
          font-weight:400;
          line-height:48rpx;
        }
      }
      .btm {
        height: 100rpx;
        line-height: 100rpx;
        display: flex;
        font-size:34rpx;
        font-family:PingFangSC-Regular,PingFangSC;
        font-weight:400;
        .sure {
          background:#4A64EA;
          color: #fff;
        }
        span {
          flex: 1;
          text-align: center;
        }
        span:nth-child(1) {
          background: #f9f9f9;
        }
        span:nth-child(2) {
          background:#4A64EA;
          color: #fff;
        }
      }
    }
}
.commonModal {
  flex:1;
  width: 100%;
  top: 0rpx;
  background: #fff;
  z-index: 999;
}
.gifToast {
  position: fixed;
  background-color: rgba(0, 0, 0, 0.65);
  color: #fff;
  text-align: center;
  top: 47.5%;
  left: 50%;
  transform: translateX(-50%);
  padding: 22rpx 44rpx;
  border-radius: 13rpx;
  font-size: 28rpx;
}
.mask {
  position: absolute;
  height: 100%;
  width: 100%;
  top: 0;
  z-index: 10;
  background-color: rgba(255, 255, 255, 0);
}
</style>
